package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/8/19 21:15
 */
public class FindOperation implements IOPreparation{
    public void work(BookList bookList){
        System.out.println("请输入要查找的书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = bookList.getSize();
        int i = 0;
        for (; i <currentSize ; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                System.out.println("已找到书，信息如下");
                System.out.println(book);
                return;
            }
            }
        if (i == currentSize ){
            System.out.println("查无此书");
        }

    }
}
